<template>
  <div class="data-v-sr">
    <div class="box" :style="sty">
      <img :src="src" alt="" width="28" height="32" v-if="icon" />
      <div class="name">{{ name }}</div>
      <div class="value">{{ formattedValue }}</div>
    </div>
  </div>
</template>

<script>
import { modifyOpacity } from "../color";
import { formatNum } from "../utils";
import pic1 from "./img/pic1.png";
export default {
  name: "data-v-summary-rect",
  props: {
    value: {
      type: [String, Number],
      default: 123456789
    },
    name: {
      type: String,
      default: "默认数据名称"
    },

    color: {
      type: String,
      default: "#fff"
    },

    icon: {
      type: String,
      default: ""
    },

    padding: {
      type: [String, Number],
      default: 0
    }
  },
  computed: {
    formattedValue() {
      return formatNum(this.value);
    },
    sty() {
      return {
        borderColor: this.color,
        backgroundColor: modifyOpacity(this.color, 0.3),
        margin: this.padding + "px"
      };
    },
    src() {
      if (this.icon) {
        return this.icon;
      }
      return pic1;
    }
  },
  mounted() {},

  methods: {}
};
</script>
<style lang="less">
.data-v-sr {
  display: flex;
  width: 268px;
  height: 50px;
  margin: 10px;
  .box {
    display: flex;
    justify-content: space-around;
    align-items: center;
    width: 100%;
    // margin: 5px;
    border: 1px solid #fff;
    background: rgba(255, 255, 255, 0.3);
    .name {
      opacity: 0.8;
      font-size: 14px;
    }
    .value {
      font-weight: 400;
    }
  }
}
</style>
